//
//  NickNameVC.m
//  StandardizedProduct
//
//  Created by 洛水寒 on 16/7/25.
//  Copyright © 2016年 ym. All rights reserved.
//

#import "NickNameVC.h"

@interface NickNameVC ()

@end

@implementation NickNameVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    //设置导航栏
    [self setNav];
    
    [self setView];
}

- (void)setNav{
    self.title = @"编辑昵称";
    self.edgesForExtendedLayout = UIRectEdgeNone;//跳过64
    self.view.backgroundColor = BackgroundCOLOR;
    
    UIBarButtonItem *done = [[UIBarButtonItem alloc] initWithTitle:@"确认" style:UIBarButtonItemStylePlain target:self action:@selector(affirmNickName)];
    self.navigationItem.rightBarButtonItem = done;
}
- (void)setView{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 10, SCREEN_WIDTH, 40)];
    view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view];
    
    
    UITextField *nickName = [[UITextField alloc] initWithFrame:CGRectMake(10, 0, SCREEN_WIDTH - 10, 40)];
    nickName.backgroundColor = [UIColor whiteColor];
    nickName.clearButtonMode = UITextFieldViewModeWhileEditing;
    nickName.text = _nick;
    [view addSubview:nickName];
}

- (void)affirmNickName{
//    [self showAlert:@"确认使用该昵称?"];
    [self.navigationController popViewControllerAnimated:YES];
}
//弹出警示框
- (void)showAlert:(NSString *)string{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:[NSString stringWithFormat:@"%@", string] message:nil preferredStyle:UIAlertControllerStyleAlert];
    
    UIAlertAction *done = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *done) {
        NSLog(@"network-------");
        [self.navigationController popViewControllerAnimated:YES];
    }];
    [alert addAction:done];
    
    UIAlertAction *cancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    [alert addAction:cancle];
    
    [self presentViewController:alert animated:YES completion:nil];
}

@end
